// import { UserInfo } from "os"
import { UserInfo } from "./account"
import { ITab } from "./tab"
import { IBasicUser } from "./user"

export type ISort = 'time' | 'like' | 'save'

export interface IBasicArticle {
  title: string
  author: IBasicUser
  content: string
  tabs: ITab[]
  like: string[]
  save: string[]
}

export interface IAddArticleParam {
  title: string
  author: string
  content: string
  tabs: ITab[]
  like: string[]
  save: string[]
}

export interface ISingleArticle extends IBasicArticle {
  id: string
  create_Ts: string
  comments: IComment[]
  status: number
}

export const exampleArticle: ISingleArticle = {
  id: "",
  title: "",
  content: "",
  author: {
    id: "",
    avatar: "",
    nickname: "",
    account: "",
    role: "normal"
  },
  status: 1,
  save: [],
  like: [],
  comments: [],
  create_Ts: "",
  tabs: []
}

export interface IComment {
  id: string
  content: string
  author: IBasicUser
  create_Ts: string
  atricleId: string
  reply: IReply[]
  like: string[]
  status: number
}

export interface IReply {
  id: string
  targetUser: UserInfo
  content: string
  create_Ts: string
  status: number
  author: UserInfo
  like: string[]
  commentId: string
  articleId: string
}

export interface IRequestArticleParam {
  authorId?: string
  offset?: number
  limit?: number
  sort?: ISort
  keyword?: string
  tab?: string | undefined
}

export interface IGoodSaveParam {
  type: 'article' | 'comment' | 'reply'
  articleId: string
  userId: string
  commentId?: string
  replyId?: string
}

export interface IAddCommentParam {
  authorId: string
  articleId: string
  content: string
}

export interface IAddReply {
  articleId: string
  authorId: string
  content: string
  commentId: string
  targetUserId: string
}